package io.github.xyzboom.cj.data

import DebugSession
import io.github.xyzboom.cj.vscode

private val debugDataCache = HashMap<DebugSessionId, DebugData>()

value class DebugSessionId(val id: String)

fun cleanCurrentData() {
    val id = DebugSessionId(currentDebugSession?.id ?: return)
    debugDataCache.remove(id)
}

val currentDebugSession: DebugSession? get() = vscode.debug.activeDebugSession

val currentDebugData: DebugData? get() = currentDebugSession?.debugData

val DebugSession.debugData: DebugData get() = debugDataCache.getOrPut(DebugSessionId(id)) { DebugData(this) }

